﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="juhtimisoigus", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Juhtimisoigus))]
    public class JuhtimisoigusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IJuhtimisoigus clazz;
        
        public JuhtimisoigusSerializer(IJuhtimisoigus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("olek");
            if (clazz.Olek!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Olek))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Olek");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oleku_aeg");
            if (clazz.OlekuAeg!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OlekuAeg))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OlekuAeg");
            }
            Writer.WriteEndElement();
            if (clazz.JuhtimisoigusPeatAlgKp!=null) {
                Writer.WriteStartElement("juhtimisoigus_peat_alg_kp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.JuhtimisoigusPeatAlgKp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.JuhtimisoigusPeatLoppKp!=null) {
                Writer.WriteStartElement("juhtimisoigus_peat_lopp_kp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.JuhtimisoigusPeatLoppKp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Alus!=null) {
                Writer.WriteStartElement("alus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Alus))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("markus");
            if (clazz.Markus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Markus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Markus");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "olek")) {
                goto olek;
            }
            else {
                if ((Reader.LocalName == "oleku_aeg")) {
                    goto oleku_aeg;
                }
                else {
                    if ((Reader.LocalName == "juhtimisoigus_peat_alg_kp")) {
                        goto juhtimisoigus_peat_alg_kp;
                    }
                    else {
                        if ((Reader.LocalName == "juhtimisoigus_peat_lopp_kp")) {
                            goto juhtimisoigus_peat_lopp_kp;
                        }
                        else {
                            if ((Reader.LocalName == "alus")) {
                                goto alus;
                            }
                            else {
                                if ((Reader.LocalName == "markus")) {
                                    goto markus;
                                }
                                else {
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        olek:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhtimisoigus>olek");
            }
            clazz.Olek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("olek")).Value;
            goto START;
        oleku_aeg:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhtimisoigus>oleku_aeg");
            }
            clazz.OlekuAeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oleku_aeg")).Value;
            goto START;
        juhtimisoigus_peat_alg_kp:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhtimisoigus>juhtimisoigus_peat_alg_kp");
            }
            clazz.JuhtimisoigusPeatAlgKp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("juhtimisoigus_peat_alg_kp")).Value;
            goto START;
        juhtimisoigus_peat_lopp_kp:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhtimisoigus>juhtimisoigus_peat_lopp_kp");
            }
            clazz.JuhtimisoigusPeatLoppKp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("juhtimisoigus_peat_lopp_kp")).Value;
            goto START;
        alus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhtimisoigus>alus");
            }
            clazz.Alus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("alus")).Value;
            goto START;
        markus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhtimisoigus>markus");
            }
            clazz.Markus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("markus")).Value;
            goto START;
        }
    }
}
